package com.harmontronics.hanma.paas.paas.controller;

import com.harmontronics.hanma.paas.paas.domain.iam.entity.GroupManage;
import com.harmontronics.hanma.paas.paas.domain.iam.entity.GroupManageUser;
import com.harmontronics.hanma.paas.paas.service.IHmUserGroupManageService;
import com.harmontronics.hanma.paas.paas.utils.MyBeanUtils;
import java.util.List;

import com.harmontronics.hanma.paas.paas.common.ResponseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.harmontronics.hanma.paas.paas.service.HmUserGroupManageAppService;
import com.harmontronics.hanma.paas.paas.dto.iam.input.HmUserGroupManageCreateInput;


/**
 * ${comments}
 *
 * @author paas-generator
 * @email paas-generator@harmontronics.com
 * @date 2021-04-07 10:35:20
 */
@RestController
@RequestMapping("/api/hmusergroupmanage")
@Api(tags = {"[权限]用户组->管理员管理"})
public class HmUserGroupManageController {
    @Autowired
    private IHmUserGroupManageService hmUserGroupManageappService;

    @GetMapping("/list")
    @ApiOperation(value = "获取用户组的管理员")
    public ResponseEntity<List<GroupManageUser>> list(@RequestParam Long groupId) {
        return ResponseEntity.ok(hmUserGroupManageappService.selectGroupManageUserWithId(groupId));
    }

    @PostMapping
    @ApiOperation(value = "新增用户组的管理员")
    public ResponseEntity create(@RequestBody List<HmUserGroupManageCreateInput> groupManageCreateList) {
        List<GroupManage> groupManageList = MyBeanUtils.batchTransform(GroupManage.class,groupManageCreateList);
        hmUserGroupManageappService.create(groupManageList);
        return ResponseEntity.ok();
    }

    @DeleteMapping
    @ApiOperation(value = "删除用户组的管理员")
    public ResponseEntity delete(@RequestParam Long id) {
        hmUserGroupManageappService.removeManagerById(id);
        return ResponseEntity.ok();
    }

}
